﻿<Window x:Class="LogicCircuit.DialogGraphicsArray"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:lc="clr-namespace:LogicCircuit"
	xmlns:properties="clr-namespace:LogicCircuit.Properties"
	WindowStartupLocation="CenterOwner"
	Title="{x:Static properties:Resources.NameGraphicsArray}"
	Style="{StaticResource DialogWindow}"
	MinWidth="420"
	MinHeight="320"
	FocusManager.FocusedElement="{Binding ElementName=writeOn}"
>
	<Window.Resources>
		<ControlTemplate x:Key="validationTemplate">
			<StackPanel Orientation="Horizontal">
				<TextBlock Foreground="Red" FontSize="20">!</TextBlock>
				<Border BorderBrush="Red" BorderThickness="1">
					<AdornedElementPlaceholder/>
				</Border>
			</StackPanel>
		</ControlTemplate>

		<Style x:Key="sizeEditor" TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
			<Setter Property="HorizontalAlignment" Value="Left"/>
			<Setter Property="MaxLength" Value="3"/>
			<Setter Property="Width" Value="{Binding ElementName=dataBitWidth, Path=ActualWidth}"/>
			<Setter Property="Validation.ErrorTemplate" Value="{StaticResource validationTemplate}"/>
			<Setter Property="SpellCheck.IsEnabled" Value="False"/>
		</Style>
	</Window.Resources>

	<lc:AutoGrid>
		<Label Content="{x:Static properties:Resources.TitleWriteOn}"/>
		<lc:AutoWidthComboBox x:Name="writeOn"
			ToolTip="{x:Static properties:Resources.ToolTipRamWriteOn}"
		/>

		<Label Content="{x:Static properties:Resources.TitleMemoryOnStart}"/>
		<lc:AutoWidthComboBox x:Name="onStart"
			ToolTip="{x:Static properties:Resources.ToolTipMemoryOnStart}"
		/>

		<Label Content="{x:Static properties:Resources.TitleDataBitWidth}"/>
		<ComboBox Name="dataBitWidth" ToolTip="{x:Static properties:Resources.ToolTipDataBitWidth}"
			HorizontalAlignment="Left"
		/>

		<Label Content="{x:Static properties:Resources.TitleGraphicsArrayBPP}"/>
		<ComboBox Name="bitsPerPixel" ToolTip="{x:Static properties:Resources.ToolTipGraphicsArrayBPP}"
			Width="{Binding ElementName=dataBitWidth, Path=ActualWidth}"
			HorizontalAlignment="Left"
		/>

		<Label Content="{x:Static properties:Resources.TitleWidth}"/>
		<TextBox Name="width" Style="{StaticResource sizeEditor}"
			Text="{Binding Path=GraphicsArrayWidth, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"
			ToolTip="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent, FallbackValue={x:Static properties:Resources.ToolTipGraphicsArrayWidth}}"
		/>

		<Label Content="{x:Static properties:Resources.TitleHeight}"/>
		<TextBox Name="height" Style="{StaticResource sizeEditor}"
			Text="{Binding Path=GraphicsArrayHeight, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"
			ToolTip="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent, FallbackValue={x:Static properties:Resources.ToolTipGraphicsArrayHeight}}"
		/>

		<Label Content="{x:Static properties:Resources.TitleDescription}"/>
		<TextBox Name="note" AcceptsReturn="True"/>

		<StackPanel Grid.ColumnSpan="2" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom">
			<Button Name="buttonOk" Content="{x:Static properties:Resources.TitleOK}" IsDefault="True" Click="ButtonOkClick"/>
			<Button Content="{x:Static properties:Resources.TitleCancel}" IsCancel="True"/>
		</StackPanel>
	</lc:AutoGrid>
</Window>
	